
from PyQt4 import QtGui,QtCore
from ftllibs.FTL import CHAMPS as CHAMPS
from ftllibs.FTL import ITEMS as ITEMS
from ftllibs.FTL import BuildDS as BuildDS
from ftllibs.FTL import MasteriesDS as MasteriesDS
from ftllibs.ui.UI_ChampDisplay import UI_ChampDisplay
from ftllibs.ui.UI_ItemMenu import ItemMenu
import copy

class BuildTab(QtGui.QWidget):
    def __init__(self,ChampID):
        super(BuildTab,self).__init__()
        self.MasterLayout = QtGui.QGridLayout()
        self.setLayout(self.MasterLayout)
        self.ChampID=ChampID
        self.Champ = CHAMPS.GetChampCopy(ChampID)
        self.unsaved=False
        self.NewBuild=True
        self.initUI()

    def initUI(self):
        self.view = QtGui.QListView()
        self.model=BuildDS.GetBuildDataModel(self.ChampID)
        self.view.setModel(self.model)
        self.view.setFixedWidth(300)
        self.view.setContextMenuPolicy(3) # Qt.CustomContextMenu
        self.BuildNameLabel = QtGui.QLabel('<h1>New Unsaved Build</h1>')
        self.AddBuildButton=QtGui.QPushButton('Add')
        self.SaveBuildButton=QtGui.QPushButton('Save')
        self.ButtonLayout=QtGui.QGridLayout()
        self.ButtonLayout.addWidget(self.AddBuildButton,0,0,1,2)
        self.ButtonLayout.addWidget(self.SaveBuildButton,1,0,1,2)
        self.ItemMenu=ItemMenu(self)
        self.Build=BuildDisplay(self)
        self.NumberedStats = NumberedStats(self)
        self.MasterLayout.addLayout(self.ButtonLayout,0,0,1,1)
        self.MasterLayout.addWidget(self.view,1,0,2,1)
        self.IconAndNameLayout=QtGui.QHBoxLayout()
        self.ChampDisplay=UI_ChampDisplay(parent=self,ChampID=self.ChampID)
        print "BuildTab: self.ChampDisplay: ",self.ChampDisplay
        self.SetChampLevel(18)
        self.IconAndNameLayout.addWidget(self.ChampDisplay)
        self.IconAndNameLayout.addWidget(self.BuildNameLabel,QtCore.Qt.AlignHCenter)
        self.MasterLayout.addLayout(self.IconAndNameLayout,0,2,1,1,QtCore.Qt.AlignHCenter)
        self.MasterLayout.addWidget(self.Build,1,2,1,1,QtCore.Qt.AlignHCenter)
        self.MasterLayout.addWidget(self.NumberedStats,2,2,1,1)
        self.MasterLayout.addWidget(self.ItemMenu,0,3,3,1)
        self.AddBuildButton.clicked.connect(self.AddBuild)
        self.SaveBuildButton.clicked.connect(self.SaveBuild)
        self.Build.BuildChange.connect(self.NumberedStats.UpdateStats)
        self.MasteriesSelect=QtGui.QComboBox()
        self.MasteriesModel=MasteriesDS.GetMasteriesDataModel()
        self.MasteriesSelect.setModel(self.MasteriesModel)
        self.MasteriesSelect.currentIndexChanged[int].connect(self.SetChampMasteries)
        self.MasterLayout.addWidget(self.MasteriesSelect,3,2,1,1)
        self.view.clicked.connect(self.LoadBuild)
        self.view.customContextMenuRequested.connect(self.CustomContext)
        self.ChampDisplay.ChampLevelChange.connect(self.SetChampLevel)
        # send to Compare Mennu
        self.SendToCompMenu=QtGui.QMenu(self)
        self.SendToCompMenu.setTitle('Compare')
        sendtoCompareSlot1Action = QtGui.QAction('Slot 1',self)
        sendtoCompareSlot2Action = QtGui.QAction('Slot 2',self)
        sendtoCompareSlot3Action = QtGui.QAction('Slot 3',self)
        sendtoCompareSlot4Action = QtGui.QAction('Slot 4',self)
        self.SendToCompMenu.addAction(sendtoCompareSlot1Action)
        self.SendToCompMenu.addAction(sendtoCompareSlot2Action)
        self.SendToCompMenu.addAction(sendtoCompareSlot3Action)
        self.SendToCompMenu.addAction(sendtoCompareSlot4Action)
        self.SendToVSMenu=QtGui.QMenu(self)
        self.SendToVSMenu.setTitle('Versus')
        sendtoVSPlayer1Action = QtGui.QAction('Player 1',self)
        sendtoVSPlayer2Action = QtGui.QAction('Player 2',self)
        self.SendToVSMenu.addAction(sendtoVSPlayer1Action)
        self.SendToVSMenu.addAction(sendtoVSPlayer2Action)
        # main context menu
        self.ContextMenu=QtGui.QMenu(self)
        exportToLOLAction = QtGui.QAction('Export',self)
        renameAction = QtGui.QAction('Rename', self)
        clearAction = QtGui.QAction('Clear',self)
        clearAction.triggered.connect(self.ClearBuild)
        copyAction = QtGui.QAction('Copy',self)
        deleteAction = QtGui.QAction('Delete',self)
        deleteAction.triggered.connect(self.DeleteBuild)
        self.ContextMenu.addMenu(self.SendToCompMenu)
        self.ContextMenu.addMenu(self.SendToVSMenu)
        self.ContextMenu.addSeparator()
        self.ContextMenu.addAction(exportToLOLAction)
        self.ContextMenu.addSeparator()
        self.ContextMenu.addAction(renameAction)
        self.ContextMenu.addAction(copyAction)
        self.ContextMenu.addAction(clearAction)
        self.ContextMenu.addSeparator()
        self.ContextMenu.addAction(deleteAction)
        # special add only context menu for non valid viewlist indexes
        self.AddContextMenu=QtGui.QMenu(self)
        addAction = QtGui.QAction('Add Build',self)
        self.AddContextMenu.addAction(addAction)
        addAction.triggered.connect(self.AddBuild)

    def CustomContext(self,pos):
        index=self.view.indexAt(pos)
        if index.isValid():
            self.ContextMenu.exec_(self.view.mapToGlobal(pos))
        else:
            self.AddContextMenu.exec_(self.view.mapToGlobal(pos))

    def ClearBuild(self):
        self.Champ.ClearBuild()
        self.unsaved=True

    def Update(self):
        pass

    def AddBuild(self):
        text,ok = QtGui.QInputDialog.getText(self,'Add New Build','Name your build:',text='Unnamed Build')
        if ok:
            lastrow=self.model.rowCount()
            print "AddBuild: lastrow: ", lastrow
            self.model.insertRows(lastrow,1,text)
            index = self.model.createIndex(lastrow,0)
            self.view.setCurrentIndex(index)
            if self.NewBuild:
                self.NewBuild=False
                self.SaveBuild()
                self.LoadBuild()
            else:
                self.LoadBuild()

    def SetChampLevel(self,lvl):
        self.Champ.SetChampLevel(lvl)
        self.NumberedStats.UpdateStats()

    def SetChampMasteries(self,masteriesID):
        MID=self.MasteriesModel.getMID(masteriesID)
        masteries=self.MasteriesModel.loadMasteries(MID)
        self.Champ.SetMasteries(masteries)
        self.NumberedStats.UpdateStats()

    def DeleteBuild(self):
        ok = QtGui.QMessageBox.question(self,'Delete Build',"Do you realy want to delete\nInsert Build name here\n","Yes","No")
        if ok == 0:
            index = self.view.currentIndex()
            self.model.removeRows(index.row(),1)

    def SaveBuild(self):
        if self.NewBuild:
            self.AddBuild()
        else:
            build = self.Build.getBuild()
            self.model.saveBuild(build)
            self.unsaved=False

    def LoadBuild(self):
        self.CheckSave()
        self.Build.clearBuild()
        index=self.view.currentIndex()
        BID=self.model.getBID(index.row())
        self.Build.setBuild(self.model.loadBuild(BID))
        self.BuildNameLabel.setText(self.Build.Name)
        self.NewBuild=False
        self.unsaved=False

    def RequestClose(self):
        print "BuildTab -> RequestClose called"
        self.close()

    def CheckSave(self):
        if self.unsaved:
            ok = QtGui.QMessageBox.question(self,'Save Changes ?',"Do you want to save your changes ?","Yes","No")
            if ok == 0:
                self.SaveBuild()


class BuildDisplay(QtGui.QWidget):
    BuildChange = QtCore.pyqtSignal()
    def __init__(self,parent):
        super(BuildDisplay,self).__init__()
#        self.setAutoFillBackground(False)
#        self.setStyleSheet("QWidget { background-color: red }")
        self.ChampID = parent.ChampID
        self.Champ = parent.Champ
        self.parent = parent
        self.setFixedSize(500,74)
        self.setAcceptDrops(True)
        self.MasterLayout = QtGui.QGridLayout()
        self.ItemLayout = QtGui.QHBoxLayout()
        self.ItemLayout.setSpacing(1)
        self.ItemLayout.setAlignment(QtCore.Qt.AlignLeft)
        self.setLayout(self.MasterLayout)
        self.BID=""
        self.NoItemPix=QtGui.QPixmap("images/icons/cross_normal_hover.png")
        self.Name=""

    def paintEvent(self,e):
        painter = QtGui.QPainter(self)
        pen = QtGui.QPen()
        brush = QtGui.QBrush()
        brush.setColor(QtGui.QColor(0,0,0))
        brush.setStyle(1)
        pen.setWidth(3)
        pen.setBrush(brush)
        pen.setColor(QtGui.QColor(0,200,0))
        painter.setPen(pen)
        painter.drawRoundedRect(4,0,72,72,6,6)
        painter.drawRoundedRect(88,0,72,72,6,6)
        painter.drawRoundedRect(172,0,72,72,6,6)
        painter.drawRoundedRect(256,0,72,72,6,6)
        painter.drawRoundedRect(340,0,72,72,6,6)
        painter.drawRoundedRect(424,0,72,72,6,6)
        for i in range(1,7):
            if not self.Champ.Build[str(i)]:
                painter.drawPixmap(26+84*(i-1),20,self.NoItemPix)
            else:
                painter.drawPixmap(9+84*(i-1),4,self.Champ.Build[str(i)].IconData.Default)

    def dragEnterEvent(self,e):
        e.accept()

    def mouseReleaseEvent(self,e):
        position = e.pos()
        pos = False
        print "BuildItemDisplay: mouseReleaseEvent: \"%s\"" % (position)
        if position.x() > 4 and position.x() < 72:
            pos = 1
        elif position.x() >= 88 and position.x() < 88+77:
            pos = 2
        elif position.x() >= 172 and position.x() < 172+77:
            pos = 3
        elif position.x() >= 256 and position.x() < 256+77:
            pos = 4
        elif position.x() >= 340 and position.x() < 340+77:
            pos = 5
        elif position.x() >= 424 and position.x() < 424+77:
            pos = 6
        if pos:
            self.delItem(pos)
            self.update()

    def dropEvent(self,e):
        item = e.mimeData().text()
        position = e.pos()
        pos = 1
        print "BuildItemDisplay: drop action: \"%s\";\"%s\"" % (item,position)
        if position.x() > 4 and position.x() < 72:
            pos = 1
        elif position.x() >= 88 and position.x() < 88+77:
            pos = 2
        elif position.x() >= 172 and position.x() < 172+77:
            pos = 3
        elif position.x() >= 256 and position.x() < 256+77:
            pos = 4
        elif position.x() >= 340 and position.x() < 340+77:
            pos = 5
        elif position.x() >= 424 and position.x() < 424+77:
            pos = 6
        self.addItem(pos,item)
        self.update()

    def setBuild(self,build):
        self.clearBuild()
        print "BuildDisplay: setBuild: 'build':" ,build
        for i in range(1,7):
            itemid=build["Item%s" % (i)]
            if not itemid == "None":
                self.addItem(i,itemid)
        self.Name="<h1>%s</h1>" % (build['Name'])

    def clearBuild(self):
        self.Champ.ClearBuild()
        self.BuildChange.emit()
        self.update()
#        self.parent.unsaved=True

    def addItem(self,pos,itemid):
        self.Champ.AddItem(str(pos),itemid)
        self.update()
        self.BuildChange.emit()
        self.parent.unsaved=True

    def delItem(self,pos):
        self.Champ.DelItem(str(pos))
        self.update()
        self.BuildChange.emit()
        self.parent.unsaved=True

    def getBuild(self):
        return self.Champ.Build


class NumberedSkillDamage(QtGui.QWidget):
    def __init__(self,parent):
        super(NumberedSkillDamage,self).__init__()
        self.MasterLayout.QtGui.QGridLayout()
        self.setLayout(self.MasterLayout)
        self.Champ=parent.Champ
        self.InitUI()

    def InitUI(self):
        pass
        
class NumberedStats(QtGui.QWidget):
    def __init__(self,parent):
        super(NumberedStats,self).__init__()
        self.MasterLayout=QtGui.QGridLayout()
        self.MasterLayout.setVerticalSpacing(30)
        self.setLayout(self.MasterLayout)
        self.Champ=parent.Champ
        self.InitUI()
        self.UpdateStats()

    def InitUI(self):
        # health
        self.L_Health=QtGui.QVBoxLayout()
        self.LBL_Health=QtGui.QLabel('Health\n')
        self.LE_Health=QtGui.QLineEdit()
        self.LE_Health.setReadOnly(True)
        self.LE_Health.setText('0')
        self.LE_Health.setMaximumWidth(100)
        self.L_Health.addWidget(self.LBL_Health)
        self.L_Health.addWidget(self.LE_Health)
        self.L_Health.addStretch()
        # mana
        self.L_Mana=QtGui.QVBoxLayout()
        self.LBL_Mana=QtGui.QLabel('Mana\n')
        self.LE_Mana=QtGui.QLineEdit()
        self.LE_Mana.setReadOnly(True)
        self.LE_Mana.setText('0')
        self.LE_Mana.setMaximumWidth(100)
        self.L_Mana.addWidget(self.LBL_Mana)
        self.L_Mana.addWidget(self.LE_Mana)
        self.L_Mana.addStretch()
        # Health Regen
        self.L_Health_Regen_per_5_seconds=QtGui.QVBoxLayout()
        self.LBL_Health_Regen_per_5_seconds=QtGui.QLabel('Health Regen\nper 5s (per 1s)')
        self.LE_Health_Regen_per_5_seconds=QtGui.QLineEdit()
        self.LE_Health_Regen_per_5_seconds.setReadOnly(True)
        self.LE_Health_Regen_per_5_seconds.setText('0')
        self.LE_Health_Regen_per_5_seconds.setMaximumWidth(100)
        self.L_Health_Regen_per_5_seconds.addWidget(self.LBL_Health_Regen_per_5_seconds)
        self.L_Health_Regen_per_5_seconds.addWidget(self.LE_Health_Regen_per_5_seconds)
        self.L_Health_Regen_per_5_seconds.addStretch()
        # Mana Regen
        self.L_Mana_Regen_per_5_seconds=QtGui.QVBoxLayout()
        self.LBL_Mana_Regen_per_5_seconds=QtGui.QLabel('Mana Regen\nper 5s (per 1s)')
        self.LE_Mana_Regen_per_5_seconds=QtGui.QLineEdit()
        self.LE_Mana_Regen_per_5_seconds.setReadOnly(True)
        self.LE_Mana_Regen_per_5_seconds.setText('0')
        self.LE_Mana_Regen_per_5_seconds.setMaximumWidth(100)
        self.L_Mana_Regen_per_5_seconds.addWidget(self.LBL_Mana_Regen_per_5_seconds)
        self.L_Mana_Regen_per_5_seconds.addWidget(self.LE_Mana_Regen_per_5_seconds)
        self.L_Mana_Regen_per_5_seconds.addStretch()
        # Attack Damage
        self.L_Attack_Damage=QtGui.QVBoxLayout()
        self.LBL_Attack_Damage=QtGui.QLabel('Attack Damage\n')
        self.LE_Attack_Damage=QtGui.QLineEdit()
        self.LE_Attack_Damage.setReadOnly(True)
        self.LE_Attack_Damage.setText('0')
        self.LE_Attack_Damage.setMaximumWidth(100)
        self.L_Attack_Damage.addWidget(self.LBL_Attack_Damage)
        self.L_Attack_Damage.addWidget(self.LE_Attack_Damage)
        self.L_Attack_Damage.addStretch()
        # Armor
        self.L_Armor=QtGui.QVBoxLayout()
        self.LBL_Armor=QtGui.QLabel('Armor\n')
        self.LE_Armor=QtGui.QLineEdit()
        self.LE_Armor.setReadOnly(True)
        self.LE_Armor.setText('0')
        self.LE_Armor.setMaximumWidth(100)
        self.L_Armor.addWidget(self.LBL_Armor)
        self.L_Armor.addWidget(self.LE_Armor)
        self.L_Armor.addStretch()
        # Ability Power
        self.L_Ability_Power=QtGui.QVBoxLayout()
        self.LBL_Ability_Power=QtGui.QLabel('Ability Power\n')
        self.LE_Ability_Power=QtGui.QLineEdit()
        self.LE_Ability_Power.setReadOnly(True)
        self.LE_Ability_Power.setText('0')
        self.LE_Ability_Power.setMaximumWidth(100)
        self.L_Ability_Power.addWidget(self.LBL_Ability_Power)
        self.L_Ability_Power.addWidget(self.LE_Ability_Power)
        self.L_Ability_Power.addStretch()
        # Magic Resist
        self.L_Magic_Resist=QtGui.QVBoxLayout()
        self.LBL_Magic_Resist=QtGui.QLabel('Magic Resist\n')
        self.LE_Magic_Resist=QtGui.QLineEdit()
        self.LE_Magic_Resist.setReadOnly(True)
        self.LE_Magic_Resist.setText('0')
        self.LE_Magic_Resist.setMaximumWidth(100)
        self.L_Magic_Resist.addWidget(self.LBL_Magic_Resist)
        self.L_Magic_Resist.addWidget(self.LE_Magic_Resist)
        self.L_Magic_Resist.addStretch()
        # Movement_speed
        self.L_Movement_Speed=QtGui.QVBoxLayout()
        self.LBL_Movement_Speed=QtGui.QLabel('Movement Speed\n')
        self.LE_Movement_Speed=QtGui.QLineEdit()
        self.LE_Movement_Speed.setReadOnly(True)
        self.LE_Movement_Speed.setText('0')
        self.LE_Movement_Speed.setMaximumWidth(100)
        self.L_Movement_Speed.addWidget(self.LBL_Movement_Speed)
        self.L_Movement_Speed.addWidget(self.LE_Movement_Speed)
        self.L_Movement_Speed.addStretch()
        # Attack_Speed
        self.L_Attack_Speed=QtGui.QVBoxLayout()
        self.LBL_Attack_Speed=QtGui.QLabel('Attack Speed\n')
        self.LE_Attack_Speed=QtGui.QLineEdit()
        self.LE_Attack_Speed.setReadOnly(True)
        self.LE_Attack_Speed.setText('0')
        self.LE_Attack_Speed.setMaximumWidth(100)
        self.L_Attack_Speed.addWidget(self.LBL_Attack_Speed)
        self.L_Attack_Speed.addWidget(self.LE_Attack_Speed)
        self.L_Attack_Speed.addStretch()
        # Spell_Vamp
        self.L_Spell_Vamp=QtGui.QVBoxLayout()
        self.LBL_Spell_Vamp=QtGui.QLabel('Spell Vamp\n')
        self.LE_Spell_Vamp=QtGui.QLineEdit()
        self.LE_Spell_Vamp.setReadOnly(True)
        self.LE_Spell_Vamp.setText('0')
        self.LE_Spell_Vamp.setMaximumWidth(100)
        self.L_Spell_Vamp.addWidget(self.LBL_Spell_Vamp)
        self.L_Spell_Vamp.addWidget(self.LE_Spell_Vamp)
        self.L_Spell_Vamp.addStretch()
        # Life_Steal
        self.L_Life_Steal=QtGui.QVBoxLayout()
        self.LBL_Life_Steal=QtGui.QLabel('Life Steal\n')
        self.LE_Life_Steal=QtGui.QLineEdit()
        self.LE_Life_Steal.setReadOnly(True)
        self.LE_Life_Steal.setText('0')
        self.LE_Life_Steal.setMaximumWidth(100)
        self.L_Life_Steal.addWidget(self.LBL_Life_Steal)
        self.L_Life_Steal.addWidget(self.LE_Life_Steal)
        self.L_Life_Steal.addStretch()
        # Cooldown_Reduction
        self.L_Cooldown_Reduction=QtGui.QVBoxLayout()
        self.LBL_Cooldown_Reduction=QtGui.QLabel('Cooldown\nReduction')
        self.LE_Cooldown_Reduction=QtGui.QLineEdit()
        self.LE_Cooldown_Reduction.setReadOnly(True)
        self.LE_Cooldown_Reduction.setText('0')
        self.LE_Cooldown_Reduction.setMaximumWidth(100)
        self.L_Cooldown_Reduction.addWidget(self.LBL_Cooldown_Reduction)
        self.L_Cooldown_Reduction.addWidget(self.LE_Cooldown_Reduction)
        self.L_Cooldown_Reduction.addStretch()
        # Armor_Penetration        # Armor_Penetration
        self.L_Armor_Penetration=QtGui.QVBoxLayout()
        self.LBL_Armor_Penetration=QtGui.QLabel('Armor\nPenetration')
        self.LE_Armor_Penetration=QtGui.QLineEdit()
        self.LE_Armor_Penetration.setReadOnly(True)
        self.LE_Armor_Penetration.setText('0')
        self.LE_Armor_Penetration.setMaximumWidth(100)
        self.L_Armor_Penetration.addWidget(self.LBL_Armor_Penetration)
        self.L_Armor_Penetration.addWidget(self.LE_Armor_Penetration)
        self.L_Armor_Penetration.addStretch()
        # Magic_Penetration
        self.L_Magic_Penetration=QtGui.QVBoxLayout()
        self.LBL_Magic_Penetration=QtGui.QLabel('Magic\nPenetration')
        self.LE_Magic_Penetration=QtGui.QLineEdit()
        self.LE_Magic_Penetration.setReadOnly(True)
        self.LE_Magic_Penetration.setText('0')
        self.LE_Magic_Penetration.setMaximumWidth(100)
        self.L_Magic_Penetration.addWidget(self.LBL_Magic_Penetration)
        self.L_Magic_Penetration.addWidget(self.LE_Magic_Penetration)
        self.L_Magic_Penetration.addStretch()
        # Critical_Strike_Chance
        self.L_Critical_Strike_Chance=QtGui.QVBoxLayout()
        self.LBL_Critical_Strike_Chance=QtGui.QLabel('Critical\nStrike Chance')
        self.LE_Critical_Strike_Chance=QtGui.QLineEdit()
        self.LE_Critical_Strike_Chance.setReadOnly(True)
        self.LE_Critical_Strike_Chance.setText('0')
        self.LE_Critical_Strike_Chance.setMaximumWidth(100)
        self.L_Critical_Strike_Chance.addWidget(self.LBL_Critical_Strike_Chance)
        self.L_Critical_Strike_Chance.addWidget(self.LE_Critical_Strike_Chance)
        self.L_Critical_Strike_Chance.addStretch()
        # put into masterlayout
        # first row
        self.MasterLayout.addLayout(self.L_Health,0,0,1,1)
        self.MasterLayout.addLayout(self.L_Health_Regen_per_5_seconds,0,1,1,1)
        self.MasterLayout.addLayout(self.L_Mana,0,2,1,1)
        self.MasterLayout.addLayout(self.L_Mana_Regen_per_5_seconds,0,3,1,1)
        # second row
        self.MasterLayout.addLayout(self.L_Attack_Damage,1,0,1,1)
        self.MasterLayout.addLayout(self.L_Armor,1,1,1,1)
        self.MasterLayout.addLayout(self.L_Ability_Power,1,2,1,1)
        self.MasterLayout.addLayout(self.L_Magic_Resist,1,3,1,1)
        # third row
        self.MasterLayout.addLayout(self.L_Movement_Speed,2,0,1,1)
        self.MasterLayout.addLayout(self.L_Attack_Speed,2,1,1,1)
        self.MasterLayout.addLayout(self.L_Critical_Strike_Chance,2,2,1,1)
        self.MasterLayout.addLayout(self.L_Cooldown_Reduction,2,3,1,1)
        # fourth row
        self.MasterLayout.addLayout(self.L_Armor_Penetration,3,0,1,1)
        self.MasterLayout.addLayout(self.L_Magic_Penetration,3,1,1,1)
        self.MasterLayout.addLayout(self.L_Life_Steal,3,2,1,1)
        self.MasterLayout.addLayout(self.L_Spell_Vamp,3,3,1,1)
        # fifth (spacer)
        self.MasterLayout.setRowStretch(4,1)
    def setChamp(self,Champ):
        self.Champ = Champ
        self.UpdateStats()

    def UpdateStats(self):
        self.LE_Health.setText(str(self.Champ.Health))
        self.LE_Mana.setText(str(self.Champ.Mana))
        self.LE_Health_Regen_per_5_seconds.setText("%s (%s)" % (str(self.Champ.Health_Regen_per_5_seconds),str(self.Champ.Health_Regen_per_5_seconds/5.0)))
        self.LE_Mana_Regen_per_5_seconds.setText("%s (%s)" % (str(self.Champ.Mana_Regen_per_5_seconds),str(self.Champ.Mana_Regen_per_5_seconds/5.0)))
        self.LE_Attack_Damage.setText(str(self.Champ.Attack_Damage))
        self.LE_Armor.setText(str(self.Champ.Armor))
        self.LE_Ability_Power.setText(str(self.Champ.Ability_Power))
        self.LE_Magic_Resist.setText(str(self.Champ.Magic_Resist))
        self.LE_Magic_Penetration.setText("%s | %s" % (str(self.Champ.Magic_Penetration_Flat),str(self.Champ.Magic_Penetration_Percentage)+"%"))
        self.LE_Armor_Penetration.setText("%s | %s" % (str(self.Champ.Armor_Penetration_Flat),str(self.Champ.Armor_Penetration_Percentage)+"%"))
        self.LE_Spell_Vamp.setText(str(self.Champ.Spell_Vamp))
        self.LE_Life_Steal.setText(str(self.Champ.Life_Steal))
        self.LE_Movement_Speed.setText(str(self.Champ.Movement_Speed))
        self.LE_Critical_Strike_Chance.setText(str(self.Champ.Critical_Strike_Chance))
        self.LE_Attack_Speed.setText(str(self.Champ.Attack_Speed))
        self.LE_Cooldown_Reduction.setText(str(self.Champ.Cooldown_Reduction))

